import { _decorator } from 'cc';
import { PanelModel } from '../../Basic/UI/PanelModel';
import { GameParams } from '../../Basic/Config/DataConfig';
import { DataMgr } from '../../Basic/Manager/DataManager';
import { PropCellType } from './PropPanel';
import { GameModel } from '../Game/GameModel';
const { ccclass } = _decorator;

@ccclass('PropModel')
export class PropModel extends PanelModel {
  className: string = 'PropModel';
  loadRes: string = 'maingame/dialog/PropPanel';

  adPropId: number;
  /** 增加道具 */
  addProp(propId: string, count: number = 1) {
    let propKey: GameParams = null;
    switch (propId) {
      case 'item_box' /** 蛋糕盒 */:
        propKey = GameParams.item_box;
        break;
      // case 2 /** 彩色蛋糕 */:
      //   propKey = GameParams.prop_2;
      //   break;
      case 'item_scoop2' /** 蛋糕铲(列) */:
        propKey = GameParams.item_scoop2;
        break;
      case 'item_scoop1' /** 蛋糕铲(行) */:
        propKey = GameParams.item_scoop1;
        break;
      // case 5 /** 左转 */:
      //   propKey = GameParams.prop_5;
      //   break;
      // case 6 /** 右转 */:
      //   propKey = GameParams.prop_6;
      //   break;
    }
    DataMgr.changeGameAttr(propKey, count);

    // 刷新游戏内数据
    GameModel.Ins().propMac.refreshAllProp();
  }

  /** 获取列表集合 */
  getListData() {
    const arr: PropCellType[] = [];
    for (let i = 0; i < 6; i++) {
      const cell = new PropCellType(i + 1);
      arr.push(cell);
    }
    return arr;
  }
}
